/*
 Author:du
 Time:2017.10.30
*/

using UnityEngine;
using UnityEngine.UI;

namespace FutureCorePlugin
{
    public class AssistUIRaycast : MonoBehaviour
    {
#if UNITY_EDITOR
        private static Vector3[] fourCorners = new Vector3[4];

        public bool isShow = true;
        private Color color = Color.blue;

        void OnDrawGizmos()
        {
            if (!isShow) return;
            Gizmos.color = color;
            foreach (MaskableGraphic g in FindObjectsOfType<MaskableGraphic>())
            {
                if (g.raycastTarget)
                {
                    RectTransform rectTransform = g.transform as RectTransform;
                    rectTransform.GetWorldCorners(fourCorners);
                    for (int i = 0; i < 4; i++)
                    {
                        Gizmos.DrawLine(fourCorners[i], fourCorners[(i + 1) % 4]);
                    }
                }
            }
        }
#endif
    }
}